﻿using GrapeCity.Forguncy.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using static hikvision_signature.hikvision_signatureServerCommand;

namespace hikvision_signature
{
    internal class shujuchuli
    {
        //定义动态数据源配置取值转换方法
        public static async Task<Dictionary<string, string>> dongtaishujuyuan (IServerCommandExecuteContext dataContext, IEnumerable<liebiaocanshu> privateDataItems)
        {
            if (privateDataItems == null || !privateDataItems.Any())
            {
                return null;  // 如果传入的参数为空或集合没有元素，返回 null
            }

            // 创建一个字典来存储卡片数据内容
            var aaa = new Dictionary<string, string>();
            if (privateDataItems != null)
            {
                foreach (var item1 in privateDataItems)
                {
                    // 将参数名和参数值转换为字符串并添加到字典中
                    var key = (await dataContext.EvaluateFormulaAsync(item1.参数名))?.ToString() ?? string.Empty;
                    var value = (await dataContext.EvaluateFormulaAsync(item1.参数值))?.ToString() ?? string.Empty;

                    if (!string.IsNullOrEmpty(key) && value != null)
                    {
                        aaa[key] = value;
                    }
                }
            }
            return aaa;
        }
         
    }
}
